import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-10-17
 * Time: 10:12
 */
public class Test {


    public static void main(String[] args) {
        TreeSet<String> set = new TreeSet<>();
        set.add("abcd");
        set.add("hello");
        set.add("world");

        //实现迭代器
        Iterator<String> it = set.iterator();
        while(it.hasNext()){
            System.out.print(it.next() + " ");
        }
        System.out.println();
    }


    public static void main12(String[] args) {
        TreeMap<String, Integer> treeMap = new TreeMap<>();
        treeMap.put("abc", 3);
        treeMap.put("hello", 2);
        treeMap.put("world", 5);

        Set<Map.Entry<String, Integer>> entrySet = treeMap.entrySet();
        for (Map.Entry<String, Integer> entry: entrySet) {
            System.out.println("key: " + entry.getKey() + " val: " + entry.getValue());
        }
        // Set<String> set = treeMap.keySet();

        //int val = treeMap.get("hello");
        //Integer val = treeMap.getOrDefault("hello2", 100);
        //System.out.println(val);
        //treeMap.remove("hello");


    }

    public static void main1(String[] args) {
        BinarySearchTree bsj = new BinarySearchTree();
        bsj.insert(10);
        bsj.insert(5);
        bsj.insert(15);
        bsj.insert(9);
        bsj.insert(3);
        bsj.insert(18);

        bsj.remove(10);
    }
}
